package org.javaboy.vhr.service;
import org.javaboy.vhr.mapper.TrainMapper;
import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.model.RespBean;
import org.javaboy.vhr.model.RespPageBean;
import org.javaboy.vhr.model.Train;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TrainService {
    @Autowired
    TrainMapper trainMapper;





    public int addTrain(Train train) {
        train.setStatus(0);
        return trainMapper.addTrain(train);

    }

    public int changeStatus(Train train) {
        return trainMapper.changeStatus(train);
    }


    public List<Train> getAllTrain() {

        return trainMapper.getAllTrain();
    }




    public RespPageBean getTrain_0( Integer page, Integer size, Integer status_id_1,Integer status_id_2) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<Train> data = trainMapper.getTrain_0(page,size,status_id_1,status_id_2);
        long total =trainMapper.getTotal(status_id_1,status_id_2);
        RespPageBean bean = new RespPageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;

    }


}
